home *** CD-ROM | disk | FTP | other *** search
/ Aminet 16 / Aminet 16 (1996)(GTI - Schatztruhe)[!][Dec 1996].iso / Aminet / misc / emu / Easy1541.lha / Easy1541 / dev / Examples / IECStatus.c < prev    next >
C/C++ Source or Header  |  1996-09-02  |  1KB  |  96 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <exec/exec.h>
  5. #include <exec/execbase.h>
  6. #include <exec/memory.h>
  7. #include <proto/exec.h>
  8. #include <proto/dos.h>
  9.  
  10. #include <iec/iec.h>
  11.  
  12. //----------------------------------------
  13. //IECStatus 1.0
  14. //
  15. //Displays the status of drive 1541
  16. //
  17. //----------------------------------------
  18.  
  19.  
  20. struct iecbase *IECBase;
  21. struct RDArgs *rda;
  22.  
  23.  
  24. LONG argv[1]={0};
  25. char device=8;    //Default device #
  26.  
  27.  
  28. char Version[]="$VER:IECStatus 1.0 (01.09.96) by Fabrizio Farenga";
  29.  
  30.  
  31.  
  32. void ReadStatus(void)
  33. {
  34.     //Ask for status
  35.     //OPEN 15,8,15
  36.     Listen(device);
  37.     Second(CMD_OPEN+15);
  38.  
  39.     if (IECBase->iec_ST!=ST_OK)
  40.         {
  41.         printf ("\n?DEVICE NOT PRESENT\n\n");
  42.         return;
  43.         }
  44.  
  45.     UnListen();
  46.  
  47.     printf ("\n");
  48.  
  49.     //Receive data
  50.     //GET#15
  51.     Talk(device);
  52.     TkSA(CMD_DATA+15);
  53.         while (IECBase->iec_ST==ST_OK) printf ("%c",ACPtr());
  54.     UnTalk();
  55.  
  56.     printf ("\n\n");
  57.  
  58.     //CLOSE
  59.     Listen(device);
  60.     Second(CMD_CLOSE+15);
  61.     UnListen();
  62. }
  63.  
  64.  
  65. void main(void)
  66. {
  67.  
  68. if ((rda = ReadArgs("Device/N",argv,NULL)) != NULL)
  69.     {
  70.     if (argv[0]!=0) device=*(LONG *)argv[0];    //Get device number
  71.     FreeArgs(rda);
  72.     }
  73.  
  74. if ((device<4)||(device>30))
  75.     {
  76.     printf ("\n?DEVICE NOT PRESENT\n\n");
  77.     return;
  78.     }
  79.  
  80. IECBase = (struct iecbase*)OpenLibrary("iec.library",0L);
  81.  
  82. if (IECBase!=0)
  83.     {
  84.  
  85.     ReadStatus();
  86.  
  87.     CloseLibrary((struct Library*)IECBase);
  88.     }
  89. else
  90.     {
  91.     printf ("Can't open iec.library\n");
  92.     return;
  93.     }
  94.  
  95. }
  96.